-- CALC_LOOSE_TILES_BONUS

-- 计算松动的地砖奖励（隐藏物件）
return function(user, bonusArg)
    local rand = DungeonM.getRandSeed("LOOSE_TILES") % 100;
    local rand2 = DungeonM.getRandSeed("LOOSE_TILES");
    local classId;
    local dungeonId = CaveHideItemM.getParentDungeonId();
    local class = bonusArg.class;
    local specialBonusCount = CaveHideItemM.getSpecialBonusCount(class);
    local arr1 = {};

    if rand < 40 and specialBonusCount <= 0 then
        -- 统计特殊奖励出现次数
        CaveHideItemM.statSpecialBonusCount(class);

        -- 冒险者の森
        if dungeonId == 1 then
            return { 1, 8059, 1 };
        end

        -- 英雄の村
        if dungeonId == 2 then
            return { 1, 7008, 2 };
        end

        -- 遗落の圣坛
        if dungeonId == 3 then
            return { 1, 7059, 3 };
        end

        -- 废弃边陲
        if dungeonId == 4 then
            return { 1, 7025, 3 };
        end

        -- 古代竞技场
        if dungeonId == 5 then
            return { { 1, 7031, 1 }, { 1, 7032, 1 }, };
        end

        -- 低语の森
        if dungeonId == 6 then
            return { 1, 8058, 1 };
        end

        -- 圣者の塔
        if dungeonId == 7 then
            return { { 1, 7042, 5 }, { 1, 7043, 5 }, };
        end

        -- 砂漠の绿洲
        if dungeonId == 8 then
            return { 1, 7031, 2 };
        end

        -- 血腥要塞
        if dungeonId == 9 then
            return { 1, 7201, 2 };
        end

        -- 德古拉城堡
        if dungeonId == 10 then
            return { 1, 7243, 1 };
        end

        -- 海贼の港
        if dungeonId == 1001 then
            return { 1, 7030, 3 };
        end

        -- 骷髅岛
        if dungeonId == 1002 then
            return { 1, 7264, 2 };
        end

        -- 阿瓦隆要塞
        if dungeonId == 1004 then
            arr1 = { 7516, 7517, 7518, };
            return { { 1, FormulaM.invoke("FETCH_BY_RAND", arr1, rand2), 10 }, };
        end

        -- 蒸汽之都
        if dungeonId == 1003 then
            return { 1, 7563, 5 };
        end
    else
        local rand1 = DungeonM.getRandSeed("LOOSE_TILES") % 100;
        local arr  = {};
        local amount;

        if rand1 < 55 then
            arr     = { { ["amount"] = 1, ["ratio"] = 100, }, { ["amount"] = 2, ["ratio"] = 100, }, { ["amount"] = 3, ["ratio"] = 100, }, };
            info  = fetchElemBySeed(arr, rand2);
            classId = FormulaM.invoke("CALC_GET_SCROLL_BY_RANK", user, 1);

            return { 1, classId, info["amount"] };
        elseif rand1 < 85 then
            arr     = { { ["amount"] = 1, ["ratio"] = 100, }, { ["amount"] = 2, ["ratio"] = 100, }, };
            info  = fetchElemBySeed(arr, rand2);
            classId = FormulaM.invoke("CALC_GET_SCROLL_BY_RANK", user, 2);

            return { 1, classId, info["amount"] };
        else
            classId = FormulaM.invoke("CALC_GET_SCROLL_BY_RANK", user, 3);

            return { 1, classId, 1 };
        end
    end

    return {};
end